-
Notifications
You must be signed in to change notification settings - Fork 9
log: C++-based backend implementation #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The created documentation from the pull request is available at: docu-html |
34f6f12 to
235d8c1
Compare
93febff to
8ff01eb
Compare
License Check Results🚀 The license check job ran with the Bazel command: bazel run //:license-checkStatus: Click to expand output |
8ff01eb to
a7e0958
Compare
a7e0958 to
50fc165
Compare
50fc165 to
cd7528c
Compare
cd7528c to
872b1af
Compare
b2792db to
dde419b
Compare
dde419b to
018f7f5
Compare
018f7f5 to
8b22ae1
Compare
|
Source code is ready, renames to be done. |
8b22ae1 to
c1ab28e
Compare
c1ab28e to
7f41f28
Compare
7f41f28 to
b950507
Compare
`mw_log` backend implementation using `baselibs`.
b950507 to
28050b6
Compare
src/rust/mw_logger/examples/main.rs
Outdated
|
|
||
| trace!("This is a trace log - hidden"); | ||
| debug!("This is a debug log - hidden"); | ||
| error!("This is an error log"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing usage with constext on default logger
| if (logger->IsLogEnabled(current)) { | ||
| return current; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hoppe-and-dreams dont we have some API to just check it instead of manually resolving it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Copy data into array. | ||
| let mut data: [c_char; 4] = [0; 4]; | ||
| unsafe { | ||
| core::ptr::copy_nonoverlapping(context.as_ptr(), data.as_mut_ptr() as *mut u8, size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cast<>() instead as
|
|
||
| impl Recorder { | ||
| pub fn new() -> Self { | ||
| let inner = unsafe { recorder_get() }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
caling C FFi shall do ptr checking. So check nullptrs ie with debug_assert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can do, but why debug_assert and not assert?
| if let Some(ref path) = self.config_path { | ||
| let path_os_str = path.as_os_str(); | ||
| if !path_os_str.is_empty() { | ||
| unsafe { set_var(KEY, path_os_str) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add #safety caluse to all unsafe stuff in this pr
| // Create log stream. | ||
| let context = metadata.context(); | ||
| let log_level = metadata.level().into(); | ||
| let log_stream = LogStream::new(&self.recorder, context, log_level); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as writen before, if internals of this failed, we can jsut skip logging here.
| } | ||
|
|
||
| // SAFETY: The underlying C++ logger is known to be thread-safe. | ||
| unsafe impl Send for ScoreLogger {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The C++ ffi types shall have sync/send markups
| /// [`score_log::fmt::ScoreWrite`] writer implementation used by [`crate::ScoreLogger`]. | ||
| /// Adds values to the log stream with selected formatting. | ||
| pub(crate) struct ScoreLoggerWriter<'a> { | ||
| log_stream: LogStream<'a>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw why not implement ScoreWrite over LogStream and doing next class here ?
| Self { recorder, slot } | ||
| } | ||
|
|
||
| pub fn log_bool(&mut self, v: &bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all those with inline hint.
mw_logbackend implementation usingbaselibs.